package com.itdr.protal.controller;


import com.itdr.common.ServerResponse;
import com.itdr.protal.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author AirZhang
 * @since 2020-10-20
 */
@RestController
@RequestMapping("/product/")
public class ProductController {
    @Autowired
    IProductService productService;


    /**
     * 商品模糊查询（分页）
     * @param keyWord
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("pli")
    public ServerResponse pli(String keyWord,
                              @RequestParam(required = false, defaultValue = "1") Integer pageNum,
                              @RequestParam(required = false, defaultValue = "5") Integer pageSize) {
        return productService.pli(keyWord, pageNum, pageSize);
    }

    /**
     * 商品详情
     * @param pid
     * @return
     */
    @GetMapping("pxq")
    public ServerResponse pxq(Integer pid) {
        return productService.pxq(pid);
    }

    /**
     * 获取推荐商品
     * @return
     */
    @GetMapping("new")
    public ServerResponse newProduct() {
        return productService.newProduct();
    }
}

